//
// Copyright 2018 Google Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions://
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.//
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

@import url("https://fonts.googleapis.com/css?family=Roboto:300,400,500,600,700");
@import url("https://fonts.googleapis.com/icon?family=Material+Icons");

// Sass
@import "./mixins";

$test-viewport-trim-color: #abc123; // Value must match `TRIM_COLOR_CSS_VALUE` in `image-cropper.js`
$test-layout-cell-grid-color: #ddd;

@mixin test-fixture-grid-bg {
  // Ruler grid pattern
  // https://stackoverflow.com/a/32861765/467582
  background-image:
    linear-gradient(to right, #{$test-layout-cell-grid-color} 1px, transparent 1.01px),
    linear-gradient(to bottom, #{$test-layout-cell-grid-color} 1px, transparent 1.01px); // fraction for IE 11

  background-size: 10px 10px;
}

@mixin test-fixture-no-bg {
  background-image: none;
}

.test-container {
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.test-container--large-font {
  font-size: 200%; // stylelint-disable-line declaration-property-unit-whitelist
}

@include test-browser-selector-edge {
  .test-container--edge-fonts {
    // stylelint-disable selector-class-pattern
    .mdc-button,
    .mdc-floating-label,
    .mdc-text-field-helper-text,
    .mdc-text-field__input {
      color: transparent !important;
    }
    // stylelint-enable selector-class-pattern
  }

  .test-container--edge-fonts .test-font--redact-all,
  .test-container--edge-fonts .test-font--redact-prev-letter {
    display: inline-block;
    background: black;
    color: black;
    z-index: 1;
  }

  .test-container--edge-fonts .test-font--redact-prev-letter {
    position: absolute;
    top: 0;
    width: 1em;
    height: 100%;
    transform: translateX(calc(-100% + 4px));
  }
}

.test-viewport {
  @include test-fixture-grid-bg;

  position: relative;
  box-sizing: border-box;
  min-width: 100vw;
  min-height: 100vh;
}

.test-viewport--mobile {
  @include test-fixture-no-bg;

  width: 350px; // fits 2 columns of buttons within a Galaxy S7 viewport
  min-width: auto;
  height: 590px; // fits 8 rows of buttons within a Galaxy S7 viewport
  min-height: auto;
  margin: 5px 0 5px 5px; // Extra padding ensures that CBT's "chromeless" screenshots don't get cut off
  border: 1px solid $test-viewport-trim-color;
  overflow: hidden;
}

.test-viewport--overflowing::after {
  display: block;
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 10px 20px;
  background-color: rgba(255, 0, 0, .5);
  color: white;
  font-family: Roboto, sans-serif;
  font-size: .9rem;
  font-weight: bold;
  text-shadow: 0 0 3px rgba(0, 0, 0, .5);
  content: "ERROR: Content overflows mobile viewport!";
}

.test-viewport--center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.test-layout {
  display: flex;
  flex-wrap: wrap;
  box-sizing: border-box;
}

.test-cell {
  @include test-fixture-grid-bg;

  box-sizing: border-box;
  margin: 1px;

  // Ensure that shadows from adjacent components don't overlap
  padding: 10px;
}

.test-cell__heading {
  height: 20px;
}

// stylelint-disable selector-max-universal
.test-animation--paused,
.test-animation--paused::before,
.test-animation--paused::after,
.test-animation--paused *,
.test-animation--paused *::before,
.test-animation--paused *::after {
  animation-play-state: paused !important;
  transition: none !important;
}
// stylelint-enable selector-max-universal

.test-redline {
  display: block;
  position: fixed;
  justify-content: center;
  width: 1px;
  height: 1px;
  background-color: currentColor;
  color: red;
  z-index: 100;
}

.test-redline--pass {
  color: green;
}

.test-redline--warn {
  color: deeppink;
}

.test-redline__tick {
  display: block;
  position: absolute;
  background-color: currentColor;
}

.test-redline--vertical .test-redline__tick {
  right: -10px;
  left: -10px;
  height: 1px;
}

.test-redline--horizontal .test-redline__tick {
  top: -10px;
  bottom: -10px;
  width: 1px;
}

.test-redline--vertical .test-redline__tick--start {
  top: 0;
}

.test-redline--vertical .test-redline__tick--end {
  bottom: 0;
}

.test-redline--horizontal .test-redline__tick--start {
  left: 0;
}

.test-redline--horizontal .test-redline__tick--end {
  right: 0;
}

.test-redline__label {
  display: block;
  position: absolute;
  padding: 2px;
  border: 1px solid #ccc;
  border-radius: 2px;
  background-color: white;
  font-family: Courier, monospace;
  font-size: 8px; // 8px is the least flaky font size in Firefox on Windows
  text-align: right;
  white-space: nowrap;
}

.test-redline--vertical .test-redline__label {
  top: 50%;
  right: 2px;
  transform: translateY(-50%);
}

.test-redline--horizontal .test-redline__label {
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
}

.test-redline--small.test-redline--vertical .test-redline__label {
  right: 13px;
}

.test-redline--small.test-redline--horizontal .test-redline__label {
  bottom: 13px;
}

.test-baseline-probe {
  display: inline-block;
  width: 0;
  height: 0;
  vertical-align: baseline;
}
